//
//  GraduallyNavAnimation.m
//  TheVideoClip
//
//  Created by huyan on 2018/4/2.
//  Copyright © 2018年 北斗君合MacMini. All rights reserved.
//

#import "GraduallyNavAnimation.h"

@interface GraduallyNavAnimation ()

//@property (nonatomic, weak) id <UIViewControllerContextTransitioning> transitionContext;

@end

@implementation GraduallyNavAnimation

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
    return 0.5;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
    UIView *presentView = [transitionContext viewForKey:UITransitionContextToViewKey];
    [[transitionContext containerView] addSubview:presentView];
    presentView.alpha = 0;
    [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
        presentView.alpha = 1.0;
    } completion:^(BOOL finished) {
        if ([self.delegate respondsToSelector:@selector(didFinishTransition)]) {
            [self.delegate didFinishTransition];
        }
        [transitionContext completeTransition:YES];
    }];
}

@end
